package com.hbu.imagePackage;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import com.hbu.housingbrokerug.activities.About;
import com.hbu.housingbrokerug.activities.Main;
import com.hbu.housingbrokerug.activities.Search;
import com.hub.R;
import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * @author Lubwama Samuel
 */
public abstract class BaseActivity extends Activity {

	protected ImageLoader imageLoader = ImageLoader.getInstance();

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.main_menu, menu);
		return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		Bundle bundle=getIntent().getExtras();
		switch (item.getItemId()) {
			case R.id.reload:			
				Intent intent = new Intent(this, Main.class);		
				intent.putExtra("CATEGORY_ID", bundle.getString("CATEGORY_ID"));
				intent.putExtra("CATEGORY_NANE", bundle.getString("CATEGORY_NAME"));
				startActivity(intent);
				finish();
				return true;
			case R.id.search_menu:
				Intent intentSearch = new Intent(this,  Search.class);
				intentSearch.putExtra("CATEGORY_ID", bundle.getString("CATEGORY_ID"));
				intentSearch.putExtra("CATEGORY_NANE", bundle.getString("CATEGORY_NAME"));
				 startActivity(intentSearch);
				 finish();
				return true;
			case R.id.about_us:
				Intent intent_about = new Intent(this, About.class);
				intent_about.putExtra("MESSAGE", "");
				startActivity(intent_about);
				return true;
			default:
				return false;
		}
	}
}
